﻿using System.Linq;
using System.Reflection;

namespace MavlinkPacketViewer.PacketViewer
{
    public static class AttributeHelper
    {
        public static TAtt GetAttribute<TAtt>(this MemberInfo propertyInfo)
        {
            var attributes = propertyInfo.GetCustomAttributes(typeof(TAtt), true);
            return (attributes.Length > 0)
                       ? attributes.OfType<TAtt>().First()
                       : default(TAtt);
        }
    }
}